// eslint-disable-next-line consistent-return

/**
 * 根据id 匹配市级数据
 * @param citylist
 * @param cityId
 * @returns
 */
export const getCityIdName = (citylist: any[], cityId: any[]) => {
	if (Array.isArray(citylist) && citylist.length > 0 && cityId && cityId !== undefined) {
		// 根据省ID 匹配当前省的数据
		const data = citylist.find((item) => item.id === cityId[0])
		// 根据市级ID 匹配当前城市ID和name
		const obj = data?.cityInfoList.find(
			(v: { id: any }) => v.id === cityId[1],
		)

		return obj
	}
	return false
}

export const getProvinceIdName = (citylist: any[], cityId: any[]) => {
	if (Array.isArray(citylist) && citylist.length > 0 && cityId && cityId !== undefined) {
		// 根据省ID 匹配当前省的数据
		const data = citylist.find((item) => item.id === cityId[0])
		// // 根据市级ID 匹配当前城市ID和name
		// const obj = data?.cityInfoList.find(
		// 	(v: { id: any }) => v.id === cityId[1],
		// )

		return data
	}
	return false
}